package com.alipay.demo;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradePrecreateModel;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.response.AlipayTradePrecreateResponse;

/**
 * @author jie
 * @date 2021/6/13 -14:22
 */
public class Test {
    public static void main(String[] args) throws AlipayApiException {
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipaydev.com/gateway.do","2016092700604570","MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCNnakZokKtwwY9awMUFEcGsNQjsWBRxc6F9/IRkbmg6gN44YkMFCtpT5IoYLlWopkWag6ZQ7pzAh47jM+V7GO4TKZBH0Lf++BHZ87HarKZH+efUng9RCgh3wixjROwlocxJigHiwn47A7mzfLVLJU3T28qxPDh/t3uPQc6t/peg/ePvZjHHn33UFmNWqHbO5lrnPqos+yFtZMqwq+hFuTcjljU/XmHkkaCngfk39PNgdlCU+4WBx/mM/10VA4ZGfvKrXgzIOgsUTUKnnPR+cV017LcCz1JAfCq+LpIRy+wP0gHdDyo09axFyIJvLOxROF1mWNowl4enOn23gb273r1AgMBAAECggEAcgWSJIiHxV40RPlHdkBJW7K+a6qiUdTBTw5uwgSiAFTKzOZSsP4AYf9mP8p5D69FMU3dSTvGAFmhO/NJJH47YCWe6uofrzYew39qdxeKi02r8ZS2KSYaZgMs/cAILXNVkJYXPtONCPYPnXgO3+LQlcMIT9hX1q6dw/cxPe7p0HSf7M8k6A01BpWpM9ZspSYGgfqcZoc0OhVZPjX0qPcTfr4grzbUdAdxyYLUcX3Gri72frVyMxYeDl5VOlvucsbeKPbxtVq4EdugF+j/iTJC/RvzNJMYVLHliYAmahkPEqJq122N/XCiKPLJ5p9mf0tMWnLeI5JCODHzUrPRuwU6tQKBgQDFXqZRqagspqxZpIgjSIzmPjU04Jqf0+/A6lA6gZPpyfb0SK0FoRnzj6zqCyBHpAJdWg5d0i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B8CgYAjPlVLuhQoiInQGNFLxRWqhCRLELxB8BUjpu00FjmkNbcP/Pv/CTBR+8lGRXRzBlYfKJlhQVxZhPk9RyzR7t0ldvhbwxY+hm7J1MJdtaPgG7ttnx3WxADDHyJGeXmv5WW9xenw/JE4+FfUrc8K85eqWyyX8H+gWmkNa5Dh1PUcnA==","json","utf-8","MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArFRJcZAzp7mEyt87ko6km3veTY4VvW1SuNEaS3/G5Zcx50KRvJNvmTjzJ6Oo3eAFvId8Ltu0dHnMfqI07jkwMDw8fgammfxpY5aa5LwmnvvhMv9snYYuF3BJQzXaeydRn+duc0L7zL5kuILNbBMECNzdyLYdGQB/xC3UgMocXN7MEBU46uv0TBARxmsP5iPwjyymuJsuypsJrnDfidNe98R792e7CnkK0Yybpyb7Z4mmg1T9pj9aWzPVYQVbGE2XOydXSe2mW42Xp9etux+UQQwllLaLLfbSO7lmvI75VM+M+kBnvpklw9Dqac29Y+ZaY0BY6jKj1Ra4CdS4ESV6DQIDAQAB","RSA2");
        AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
        AlipayTradePrecreateModel model = new AlipayTradePrecreateModel();
        request.setBizModel(model);
        model.setOutTradeNo(System.currentTimeMillis()+"");
        model.setTotalAmount("88.88");
        model.setSubject("Iphone6 16G");
        AlipayTradePrecreateResponse response = alipayClient.execute(request);
        System.out.print(response.getBody());
        System.out.print(response.getQrCode());
    }
}
